//
//  BuyOrderContentModel.m
//  quxiangtao
//
//  Created by xbmios on 2018/10/10.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "BuyOrderContentModel.h"

@implementation BuyOrderContentModel

+ (void)buyOrderContentModelWithPage:(NSInteger)page buyType:(NSString *)type successBlock:(HttpRequestSuccess)successBlock failBlock:(HttpRequestFailed)failBlock {
    
    NSLog(@"------------%@,---------------%@",[CommonUserInfo sharedInstance].user_id,type);
    
    NSString *str = [NSString stringWithFormat:@"{\"type\" : \"%@\", \"userid\" : \"%@\", \"page\" : \"%@\", \"number\" : \"%@\"}", [RSA encryptString:type publicKey:PublicKey], [RSA encryptString:[CommonUserInfo sharedInstance].user_id publicKey:PublicKey], [RSA encryptString:[NSString stringWithFormat:@"%zd", page] publicKey:PublicKey], [RSA encryptString:@"10" publicKey:PublicKey]];
    
    [PPNetworkHelper POST:@"bargain/Orderlist/index" parameters:@{@"json" : str} success:^(id responseObject) {
        
        NSLog(@"自营购买订单数据：%@", responseObject);
        
        NSArray *array = [NSArray arrayWithArray:responseObject[@"data"]];
        
        NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:responseObject];
        
        if (array.count > 0) {
            
            NSArray *modelArr = [BuyOrderContentModel mj_objectArrayWithKeyValuesArray:array];
            
            [dict removeObjectForKey:@"data"];
            [dict setObject:modelArr forKey:@"data"];
        }
        
        if (successBlock) {
            
            successBlock(dict);
        }
        
    } failure:^(NSError *error) {
        
        if (failBlock) {
            
            failBlock(error);
        }
    }];
    
}

@end
